package com.cskaoyan.mapper;

import com.cskaoyan.bean.Admin;
import com.cskaoyan.bean.AdminExample;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.sql.Timestamp;
import java.util.List;

public interface AdminMapper {
    long countByExample(AdminExample example);

    int deleteByExample(AdminExample example);

    int deleteByPrimaryKey(Integer id);

    int insert(Admin record);

    int insertSelective(Admin record);

    List<Admin> selectByExample(AdminExample example);

    Admin selectByPrimaryKey(Integer id);

    int updateByExampleSelective(@Param("record") Admin record, @Param("example") AdminExample example);

    int updateByExample(@Param("record") Admin record, @Param("example") AdminExample example);

    int updateByPrimaryKeySelective(Admin record);

    int updateByPrimaryKey(Admin record);

    Admin login(@Param("password") String password, @Param("username") String username);

    @Select("select password from cskaoyanmall_admin where username = #{username} and deleted = false")
    String selectPasswordFromDB(@Param("username") String username);

    @Update("Update cskaoyanmall_admin set last_login_ip = #{ip} where id = #{adminId}")
    int insertLastLoginIp(@Param("ip") String remoteAddr,@Param("adminId")Integer adminId);

    @Update("Update cskaoyanmall_admin set last_login_time = #{time} where id = #{adminId}")
    int insertLastLoginTime(@Param("time") Timestamp ts, @Param("adminId") Integer adminId);

}